<?php

/**
 * 链接分类
 * @author  Mr.L <349865361@qq.com>
 */

namespace app\site\admin;

class BannerClassAdmin extends \app\system\admin\SystemExtendAdmin {

    protected $_model = 'SiteBannerClass';

    /**
     * 模块信息
     */
    protected function _infoModule() {
        return [
            'info' => [
                'name' => '横幅管理',
                'description' => '管理站点中的横幅',
            ],
            'fun' => [
                'index' => true,
                'add' => true,
                'edit' => true,
                'del' => true,
            ]
        ];
    }

    public function _indexParam() {
        return [
            'keyword' => 'name'
        ];
    }

    protected function _addAssign() {
        return array(
            'classList' =>target($this->_model)->loadList()
        );
    }

    protected function _editAssign($info) {
        return array(
            'classList' =>target($this->_model)->loadList()
        );
    }

    protected function _delBefore($id) {
        $count = target('site/SiteBanner')->countList([
            'class_id' => $id
        ]);
        if ($count > 0) {
            $this->error('请先删除该横幅下的图片！');
        }
    }

}